<?php
	class Dashboard extends Model_Abstract{
		
		public function cgbDashboard(){
			$sql = 'SELECT s.jackpot, s.today_won, s.today_played, s.domain, count( * ) as user_nums
						 FROM sites AS s, users AS u WHERE s.id = u.site_id GROUP BY s.id';
			try
			{
				return $this->_connection->query($sql);
			}
			catch (Exception $e)
			{
				$this->_connection->rollBackW();
				QLog::log(__CLASS__.' '.__METHOD__.' --- '.$e->getMessage(), QLog::ERR);
				throw new Model_Exception($e->getMessage(), $e->getCode());
			}
		}
		
		public function marketDashboard(){
			/*
			select sum(m.impression) as impression, sum(m.click) as click, sum(conversion) as conversion, p.name as pub_name, 
			s.name as sub_name , s.id
			from media_data as m left join campaigns as c on m.cam_id=c.id left join publishers as p 
			on p.id=c.pub_id left join subs as s 
			on c.sub_id=s.id group by m.cam_id;
			*/
		}
		
		public function publisherDashboard($status, $time, $pub_id){
			
			// to select publisher's campaigns with the given conditions
			
			//to retrive the data from media_data
			
			/*
			select sum(m.impression) as impression, sum(m.click) as click, sum(conversion) as conversion, m. p.name as pub_name, 
			s.name as sub_name , s.id
			from media_data as m left join campaigns as c on m.cam_id=c.id left join publishers as p 
			on p.id=c.pub_id left join subs as s 
			on c.sub_id=s.id group by m.cam_id;
			*/
		}
		
	}